package Core::Record;
use strict;
use warnings;
use vars qw{ @ISA @EXPORT };
use Exporter;
use Core::MetaMap;
use Core::Attribute;

@ISA = qw( Core::MetaMap );
@EXPORT = qw (
   Record
);



sub add
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{ 
	my( $rhSelf ) = shift;	
	my( $rhMeta );
	foreach my $sName ( @_ ){
		# New meta found
		if ( not $rhSelf->exist( $sName ) ){
			$rhMeta = Attribute( $sName ); # Create Meta obj	
			# Only push the meta not in the metalist
			push @{ $rhSelf->{ LIST } }, $rhMeta;
			$rhSelf->__calIndex();	
		}
	}
	return 1;
}

sub addValueOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{ 
	my( $rhSelf ) = shift;
	my( $sName ) = shift;

	my $rhAttr = $rhSelf->assert( $sName );	
	return 0 if not $rhAttr;
	return $rhAttr->addValue( @_ );
}	

sub getValueOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{ 
	my( $rhSelf ) = shift;
	my( $sName, $sIndex ) = @_;
	
	$sIndex = 0 if not $sIndex;
	my $rhAttr = $rhSelf->assert( $sName );	
	
	return $rhAttr->getValue( $sIndex );
}	

sub setValueOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{ 
	my( $rhSelf ) = shift;
	my( $sName, $sValue, $sIndex ) = @_;
	
	$sIndex = 0 if not $sIndex;
	my $rhAttr = $rhSelf->assert( $sName );	
	
	return $rhAttr->setValue( $sIndex, $sValue );
}

sub setValuesOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{ 
	my( $rhSelf ) = shift;
	my( $sName, $raValue ) = @_;
	
	$sIndex = 0 if not $sIndex;
	my $rhAttr = $rhSelf->assert( $sName );	
	
	return $rhAttr->setValues( $raValue );
}

sub getValuesOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{ 
	my( $rhSelf ) = shift;
	my( $sName ) = @_;
	
	$sIndex = 0 if not $sIndex;
	my $rhAttr = $rhSelf->assert( $sName );	
	
	return $rhAttr->getValues( );
}

sub popValueOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{
	my( $sName ) = shift;
	my $rhAttr = $rhSelf->assert( $sName );	
	$rhAttr->
}	

sub numOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{
	my( $sName ) = shift;
	return $rhSelf->size();
}

sub valueNumOfAttr
#*****************************************************************************
# PURPOSE:
# USAGE: 
# PASSED ARGS:
# RETURN ARGS:
# $sError - Fail Error Message
#*****************************************************************************
{
	my( $sName ) = shift;

	my $rhAttr = $rhSelf->assert( $sName );	
	return $rhAttr ? $rhAttr->size() : 0;
}




1
__END__;

